package com.scy.hospitalmanager.until;

import com.scy.hospitalmanager.dao.administratordao.NurseMsgDao;
import com.scy.hospitalmanager.dao.nursedao.NurseTimeTableDao;
import com.scy.hospitalmanager.pojo.Nurse;
import com.scy.hospitalmanager.pojo.NurseTimeTable;
import com.scy.hospitalmanager.service.impl.NurseMsgServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: 获取nursename封装工具类
 * @ClassName: NurseNameUtil
 * @Author: KuonnjiArisu
 * @Date: 2021/8/23 9:25
 * @Version: 1.0
 */
public class NurseNameUtil {
    static List<String> getNurseNameList(List<Integer> timeTableList, NurseMsgDao nurseMsgDao) {
        List<String> nurseNameList = new ArrayList<String>();
//        System.out.println(timeTableList);
        for (Integer nurId : timeTableList) {
            Nurse nurse = new Nurse();
            nurse.setNurId(nurId);
            Nurse nurse1 = nurseMsgDao.getNurseById(nurse);
            nurseNameList.add(nurse1.getNurName());
            nurseNameList.add("  ");
            //System.out.println(timeTableList);
            // System.out.println(nurse1);
        }
        int i = nurseNameList.size();
        return nurseNameList;
    }

    public static List<NurseTimeTable> getNurNameList(List<NurseTimeTable> nurseTimeTableList, NurseMsgDao nurseMsgDao) {
        List<Integer> ttMorningShiftList = new ArrayList<Integer>();
        List<Integer> ttNightShiftList = new ArrayList<Integer>();
        List<Integer> ttMiddleShiftList = new ArrayList<Integer>();
        for (NurseTimeTable nurseTimeTable : nurseTimeTableList) {
            ttMorningShiftList = SplitString.ToList(nurseTimeTable.getTtMorningShift());
            ttNightShiftList = SplitString.ToList(nurseTimeTable.getTtNightShift());
            // System.out.println(ttNightShiftList);
            ttMiddleShiftList = SplitString.ToList(nurseTimeTable.getTtMiddleShift());
            nurseTimeTable.setMorningNurseName(getNurseNameList(ttMorningShiftList, nurseMsgDao));
            nurseTimeTable.setNightNurseName(getNurseNameList(ttNightShiftList, nurseMsgDao));
            nurseTimeTable.setMiddleNurseName(getNurseNameList(ttMiddleShiftList, nurseMsgDao));
        }
        return nurseTimeTableList;
    }
}
